package com.fqy.ticket.business.controller.admin;

import com.fqy.ticket.common.resp.CommonResp;
import com.fqy.ticket.common.resp.PageResp;
import com.fqy.ticket.business.req.TrainstationQueryReq;
import com.fqy.ticket.business.req.TrainstationSaveReq;
import com.fqy.ticket.business.service.TrainstationService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/train-station")
public class TrainstationAdminController {
    @Resource
    private TrainstationService trainstationService;

    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody TrainstationSaveReq req) {
        trainstationService.save(req);
        return new CommonResp<>();
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        trainstationService.delete(id);
        return new CommonResp<>();
    }

    @GetMapping("query-list")
    public CommonResp<PageResp> queryList(@Valid TrainstationQueryReq req) {
        return new CommonResp<>(trainstationService.queryList(req));
    }

}
